package com;

import com.pojo.CCc;
import com.pojo.SStudent;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author 123456
 * @description 针对表【s_student】的数据库操作Mapper
 * @createDate 2024-11-18 10:18:24
 * @Entity com.pojo.SStudent
 */
public interface SStudentMapper {

    int deleteByPrimaryKey(Long id);

    int insert(SStudent record);

    int insertSelective(SStudent record);

    SStudent selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(SStudent record);

    int updateByPrimaryKey(SStudent record);

    @Select("select * from s_student where id = #{id}")
    SStudent selectByPrimaryId(int id);

    @Update("update s_student set name = #{name}, age = #{age} where id = #{id}")
    int updateNameAndAge(SStudent sStudent);

//    @Select("select * from s_student where id = #{id}")
//    @Results({@Result(id = true, column = "id", property = "id"),
//            @Result(column = "name", property = "name"),
//            @Result(column = "age", property = "age"),
//            @Result(column = "cid", property = "cid",many = @Many(select = "com.mapper.CCcMapper.selectCCcById"))
//    })
//    SStudent selectByCid(int cid);

    @Select("SELECT * FROM s_student WHERE cid = #{cid}")
    @Results({@Result(id = true,column = "id",property = "id"),
            @Result(column = "name",property = "name"),
            @Result(column = "age",property = "age"),
//            @Result(column = "cid", property = "cid",many = @Many(select = "com.mapper.CCcMapper.selectCCcById"))
    })
    List<SStudent> selectCCcById(int id);
}
